<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>魏远商城</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" href="css/sm.css">
		<link rel="stylesheet" href="css/sm-extend.css">
		<link rel="stylesheet" href="css/ionicons.css">
		<link rel="stylesheet" href="css/details.css">
		<link rel="stylesheet" href="css/swiper-3.3.1.min.css" />
		<style type="text/css">
			#xiang1 {
				padding: 10px 12px;
				width: 100%;
			}
			
			#xiang1:after {
				content: "";
				display: block;
				clear: both;
				height: 0;
			}
			
			#xiang1 div {
				font-size: 12px;
				margin-bottom: 5px;
				float: left;
				width: 50%;
			}
			
			.add-de span {
				height: 21px;
				/*display: inline-block;*/
			}
			.add-de>span:nth-child(2){
				/*width: calc(100% - 60px);*/
			}
			.add-fo {
				display: none;
				text-align: center;
				color: #e3b436;
				padding: 7px 0px;
				border-bottom: 1px solid #ddd;
			}
		</style>
	</head>

	<body>
		<header class="bar bar-nav">
			<span class="order-back mui-action-back"><img src="img/back-le.png" height="50%"/></span>
			<div class="tab"><span>商品</span><span>详情</span><span>评价</span>
			</div>
			<!--<span class="listener"><img src="img/erji.png" height="50%"/></span>-->
		</header>
		<div class="content">
			<div class="goods">
				<div class="pic">
					<div class="swiper-container banner-swp" style="height: 16rem;">
						<div class="swiper-wrapper">

						</div>
						<!-- 如果需要分页器 -->
						<div class="swiper-pagination"></div>
					</div>
				</div>
				<div class="tell">
					<p class="name"></p>
					<p class="pro"></p>
					<div>
						<p class="disprice">￥<span class="disprice-s"></span></p>
						<p class="price">￥<span class="price-s"></span></p>		
					</div>
					<span class="alltye" style="display: none;"><span class="actity">距结束：</span><span class="hmd"></span><span class="hms"></span>：<span class="hmf"></span>：<span class="hmm"></span></span>
					<!--<p class="how"><span>6个</span></p>
                <p class="zhong"><span>单个重260-330g</span></p>
                <p class="promise"><span><img src="img/gou.png">48小时退换货</span><span><img src="img/gou.png">全程冷链</span></p>-->
					<!--<div class="d_how">-->
					<!--<div class="howsize"><p></p><div><span></span><span></span><span></span></div></div>
                	<div class="howsize"></div>-->
					<!--</div>-->
				</div>
				<div class="address">
					<p>送至</p>
					<p><img src="img/address.png"><span class="address-d"></span></p>
					<p>有货<img src="img/turn-right.png"></p>
					<div class="cler">
						<!--<p>最早<span>10-10</span>周一<span>09:00-18:00</span>送达</p>-->
					</div>
					<div class="line"></div>
					<!--<div class="line"></div>-->
				</div>
				<div class="comm-d">
					<div class="comm-pro">
						<p>评价(<span class="all-comm"></span>)</p>
						<p><span class="per"></span>好评<img src="img/turn-right-e.png"></p>
					</div>
					<div class="comment-mei">
						<div class="comm-c">
							<p>
								<span class="headpicd"></span>
								<span class="fevaname"></span>
								<!--<img class="grade" src="img/turn-right.png">-->
							</p>
							<p class="fevatime"></p>
						</div>
						<!--<p class="taste">口感<span>5</span></p>
                    <p class="level">颜值<span>5</span></p>-->
						<div class="fc-content"></div>
					</div>
					<div class="more"><span class="look-all-comm">查看全部评价</span></div>
				</div>
			</div>
			<!--anguler开始-->
			<div>
				<div id="xiang1">
					<!--<div class="add-de">
						<span><span>系列</span><span>：</span></span>
						<span>蓝海洋系列</span>
					</div>
					<div class="add-de">
						<span><span>原料</span><span>：</span></span>
						<span>原生木浆</span>
					</div>-->
					<!--<div class="add-de">
						<span><span>纸张尺寸</span><span>：</span></span>
						<span>卫生标准</span>
					</div>
					<div class="add-de">
						<span><span>适合肤质</span><span>：</span></span>
						<span>油性皮肤</span>
					</div>-->
				</div>
				<div class="add-fo">
					<span>更多参数 ></span>
				</div>
				<!--李勇开始-->
				<div id="xiang">

				</div>
				<!--李勇结束-->
			</div>
<!--anguler结束-->
			<div class="comment-wrap">
				<div>
					<div class="how-comment">
						<div>评价<span class="all-comm"></span></div>
						<div>晒图<span class="all-comm-pic"></span></div>
					</div>
				</div>
				<div class="comment-all">
					<div class="comm"></div>
					<div class="comm-pic"></div>
					<p class="morelcom">点击查看更多</p>
				</div>
			</div>
		</div>
		<div class="fixed">
			<div class="icon">
				<!--<div><img src="img/collect.png"><p>收藏</p></div>
            <div><img src="img/share.png"><p>分享</p></div>-->
			</div>
			<div class="addcarc">加入购物车</div>
		</div>

		<div class="goods-car" id="goods-car" onclick="hrefgo('tab-cart.html','car')">
			<div class="goods-car-d">
				<img src="img/car-tu.png" alt="">
				<div class="how-all">0</div>
			</div>
		</div>
		<div class="black-men" style="display: none;">
			<div class="pro-all">
				<div class="goods-pro">
					<div><span class="fgimg"></span></div>
					<div class="pro-wen">
						<p class="pric">¥<span class="price-d"></span></p>
						<!--<p class="qpric">¥<span class="qprice-d"></span></p>-->
						<p>库存<span class="sy-jian"></span>件</p>
						<p>请选择规格</p>
						<span class="cancel"><img src="img/chacha.png"></span>
					</div>
				</div>
				<div class="buy-type">
					<div class="d_how"></div>
					<div class="buy-jian">
						<span>购买数量：</span>
						<div class="jiaajian"><span class="jian">-</span><span class="howjiad">1</span><span class="jia">+</span></div>
					</div>
				</div>
				<div class="sure-go">
					确定
				</div>
			</div>
		</div>
		<div class="zblack-men" style="display: none;">
			<div class="zpro-all">
				<div class="tita">
					<span class="cancel"><img src="img/chacha.png"></span>
					<p>组合商品</p>
				</div>
				<div class="all-zcontent">
					<!--<div class="zcontent">
	    			<div>
		    			<div class="zdpic">
		    				<span></span>
		    			</div>
		    			<div class="zdtype">
		    				
		    			</div>
	    			</div>
	    			<p>¥<span></span></p>   			
	    		</div>-->
				</div>
				<div class="buy-jian">
					<span>购买数量：</span>
					<div class="jiaajian"><span class="jian">-</span><span class="zhowjiad">1</span><span class="jia">+</span></div>
				</div>
				<div class="zprice">
					<p>共计：<span class="zallprice"></span></p>
					<p>优惠价：<span class="zyouprice"></span></p>
				</div>

				<div class="zsure-go">确定</div>
			</div>
		</div>
	</body>
	<!--<script type="text/javascript" src="js/zepto.js" charset="UTF-8"></script>-->
	<script type="text/javascript" src="js/jquery-3.1.1.min.js" charset="UTF-8"></script>
	<script src="js/mui.min.js"></script>
	<script type="text/javascript" src="js/swiper-3.3.1.jquery.min.js" charset="UTF-8"></script>
	<script src="js/url.js"></script>
	<script>
//		localStorage.whereId = 353;
		showdetails();
		discuss();

		/*获取当前时间*/
		//      var date = new Date();
		//      alert(date);

		/*弹窗*/
		$('.black-men').css('height', document.body.clientHeight + 'px');
		$('.zblack-men').css('height', document.body.clientHeight + 'px');

		/*整个页面tab切换*/
		$('.tab>span').on('tap', function() {

			$(this).css('border-bottom', '2px solid #e3b436');
			$(this).siblings().css('border-bottom', 'none');
			$('.content>div').eq($(this).index()).css('display', 'block');
			$('.content>div').eq($(this).index()).siblings().css('display', 'none');
			//         alert($('.content>div').eq($(this).index()).html());
		});
		/*点击查看全部评价*/
		$('.look-all-comm').on('tap', function() {
			$('.tab>span').eq(2).css('border-bottom', '2px solid #e3b436');
			$('.tab>span').eq(2).siblings().css('border-bottom', 'none');
			$('.content>div').eq(2).css('display', 'block');
			$('.content>div').eq(2).siblings().css('display', 'none');
		})

		/*评论tab切换*/
		$('.how-comment>div').on('tap', function() {
			$(this).css({
				'color': 'white',
				'background-color': '#e3b436'
			});
			$(this).siblings().css({
				'color': '#e3b436',
				'background-color': 'white'
			});
			$('.comment-all>div').eq($(this).index()).css('display', 'block');
			$('.comment-all>div').eq($(this).index()).siblings('div').css('display', 'none');
		});

		/*点击增减功能代码*/
		$('.jiaajian').on('tap', '.jian', function(e) {
			e.stopPropagation();
			console.log($(this).siblings().text());
			if($(this).next().text() > 1) {
				//					alert($(this).attr('ornum'));

				var a = $(this).next().text();
				a--;
				$(this).next().text(a);
				//                  if($(this).parents('.cart-goods').find('.gou').hasClass('cliced')){
				//					  pricea = Number($('.allprice').text())-Number($(this).parents('.cart-goods').find('.price-dan').text());
				//					  $('.allprice').text(pricea.toFixed(2));
				//                  }
			} else if($(this).next().text() <= 2) {
				mui.toast('所购买商品不能小于1');
			}
		});

		$('.jiaajian').on('tap', '.jia', function(e) {
			//			alert($(this).prev().text());
			//			alert($('.howjiad').text());
			e.stopPropagation();
			//				alert(typeof($(this).prev().val()));
			//				alert(typeof($(this).attr('ornum')));
			if(Number($(this).prev().text()) >= Number($(this).attr('ornum'))) {
				mui.toast('库存不足 ');
			} else {
				console.log($(this).prev().text());
				var a = $(this).prev().text();
				a++;
				$(this).prev().text(a);
				//				if($(this).parents('.cart-goods').find('.gou').hasClass('cliced')) {
				//					pricea = Number($('.allprice').text()) + Number($(this).parents('.cart-goods').find('.price-dan').text());
				//					$('.allprice').text(pricea.toFixed(2));
				//				}
			}
		})

		//      	更多参数anguler开始
		$('.add-fo').click(function() {
			moreDe();
			function moreDe() {
				$.ajax({
					url: ur + '/mobile/product/detail',
					type: 'post',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.token
					},
					data: {
						"id": localStorage.whereId,
					},
					success: function(data) {
						if(data.result.meta.code == 200) {
							$('.add-fo').unbind('click');
							if(!data.result.data.comProductExtVOs) { /*非组合商品*/
								console.log(JSON.stringify(data.result.data.propVOs))
								console.log(data.result.data.propVOs.length)
								$('#xiang').append(data.result.data.detail);
								var xiangLe = data.result.data.propVOs.length;
								for(var xl = 6; xl < xiangLe; xl++) {
									var divXiang = $('<div class="add-de">' +
										'<span><span>' + data.result.data.propVOs[xl].proName + '</span><span>：</span></span>' +
										'<span>' + data.result.data.propVOs[xl].proValue + '</span>' + '</div>');
									$('#xiang1').append(divXiang);
								}
								$('.add-fo').text('已无更多').css('color','#777')
							} else {
								
							}
						}
					}
				})
			}

		})
//      	更多参数anguler结束
		var enterp = '';
		var cidarr = {};
		var zhd = {};
		/*展示商品详情*/
		function showdetails() {
			sessionStorage.seltimes = '';
			$.ajax({
				url: ur + '/mobile/product/detail',
				type: 'post',
				dataType: 'json',
				headers: {
					"X-Token": localStorage.token
				},
				data: {
					"id": localStorage.whereId,
				},
				success: function(data) {
					if(data.result.meta.code == 200) {

						if(data.result.data.enterpriseProId) {
							enterp = data.result.data.enterpriseProId;
						}

						if(data.result.data.marketingEndTimeString != null) {
							$('.alltye').css('display', 'inline-block');
						}

						if(!data.result.data.comProductExtVOs) { /*非组合商品*/
							sessionStorage.ifzhgoods = 'noo';
							var imgl = data.result.data.imgsrc;
							var imgls = imgl.split(',');
							$('.fgimg').css('background-image', 'url(' + picur + imgls[0] + ')');
							$('.price-d').text(data.result.data.newPrice);
							$('.sy-jian').text(data.result.data.enableNum);
							$('.jia').attr('ornum', data.result.data.enableNum);
							for(var k = 0; k < imgls.length; k++) {
								var div = ('<div class="swiper-slide"><img src=' + picur + imgls[k] + ' width="100%" height="100%" alt="" /></div>');
								$('.swiper-wrapper').append(div);
							}
							$(function() {
								if(imgls.length == 1) {
									var ifdong = false
								} else if(imgls.length > 1) {
									var ifdong = true
								}
								var mySwiper1 = new Swiper('.banner-swp', {
									autoplay: 3000,
									speed: 300,
									autoplayDisableOnInteraction: false,
									lazyLoading: true, // 图片懒加载
									paginationType: 'bullets',
									pagination: '.swiper-pagination',
									loop: ifdong,
								})
							})
							//							console.log(imgls);
							$('.name').text(data.result.data.shortName);
							if(data.result.data.newPrice!=data.result.data.price){                          	
//                          	$('.disprice').css('display','block');
                                var pricenew = data.result.data.newPrice;
                                
                            	$('.disprice-s').text(Math.round(pricenew * 100) / 100);
                            	$('.price-d').text(data.result.data.newPrice);
                            	$('.price-s').text(data.result.data.price);
                            	$('.price').css({"text-decoration":"line-through",'color':'#8c9495'});                              	
                            }else if(data.result.data.newPrice==data.result.data.price){
                            	$('.price').css('display','none');
                            	$('.disprice-s').text(data.result.data.price);
                            	$('.price-d').text(data.result.data.price);
                            }
							$('.price-s').text(data.result.data.price);
							$('.pro').text(data.result.data.longName);
							$('.pic>img').attr('src', picur + data.result.data.imgsrc);
							//							console.log($('.pic>img'));
							if(data.result.data.detail == null || data.result.data.detail == "null") {

								var divimg = ('<div style="margin:5rem auto 0;text-align: center;"><span style="width:35%;background-image: url(img/nogood.png);background-position: center;background-repeat: no-repeat;background-size: contain;height: 5rem;display: inline-block;" ></span><p style="color:#6a6a6a;font-size: .8rem;">暂时没有详情哦</p></div>');
								$('#xiang').append(divimg);
							} else if(data.result.data.detail != null) {
								$('#xiang').append(data.result.data.detail);
								/*Anguler开始*/
								console.log(JSON.stringify(data.result.data.propVOs))
								console.log(data.result.data.propVOs.length)
								var xiangLe = data.result.data.propVOs.length;
									if(xiangLe > 6) {
										for(var xl = 0; xl < 6; xl++) {
											var divXiang = $('<div class="add-de">' +
												'<span><span>' + data.result.data.propVOs[xl].proName + '</span><span>：</span></span>' +
												'<span>' + data.result.data.propVOs[xl].proValue + '</span>' + '</div>');
											$('#xiang1').append(divXiang);
										
										}
										$('.add-fo').css('display', 'block');
//										alert($('.add-de>span:nth-child(1)').width())
									} else {
										for(var xl = 0; xl < xiangLe; xl++) {
											var divXiang = $('<div class="add-de">' +
												'<span><span>' + data.result.data.propVOs[xl].proName + '</span><span>：</span></span>' +
												'<span>' + data.result.data.propVOs[xl].proValue + '</span>' + '</div>');
											$('#xiang1').append(divXiang);
										}
										$('.add-fo').css('display', 'none');
									}
							/*Anguler结束*/
							}
							//							console.log(data.result.data.detail);
							$('.descri').text(data.result.data.description);
							localStorage.addcarId = data.result.data.skuid;
							var imgs = $('#xiang img');
							//							console.log(imgs.attr('src'));
							//							console.log(imgs);
							for(var n = 0; n < imgs.length; n++) {
								//                  	var dimg = imgs[n];
								//                  	dimg.attr('src');
								//								console.log(imgs[n]);
								var dimg = $(imgs[n]).attr('src');
								//								console.log($(imgs[n]).attr('src'));
								if(dimg.indexOf('http')<0){
                                  	$(imgs[n]).attr('src', picur + dimg);
                                  }
							}
							$('#xiang img').css({'width':'100%','display':'block'});
							if(data.result.data.proMap.length == 0) {
								var div = $('<div style="margin-top: 20px;"><p>该商品为固定销售属性，直接确定购买哒</p></div>');
								$('.d_how').append(div);
							} else {
								for(var i = 0; i < data.result.data.proMap.length; i++) {
									//									console.log(data.result.data.proMap.length);
									var div = $('<div class="howsize"><p>' + data.result.data.proMap[i].arrit + '</p><div class=" howd" id="' + i + '"></div></div>');
									//									console.log(data.result.data.proMap[0].value[0].value);
									//									console.log(data.result.data.proMap[0].value.length);
									$('.d_how').append(div);
									for(var y = 0; y < data.result.data.proMap[i].value.length; y++) {
										//										console.log(data.result.data.proMap[i].value[y].value);
										var span = $('<span class="' + data.result.data.proMap[i].value[y].id + '">' + data.result.data.proMap[i].value[y].value + '</span>');
										$('#' + i + '').append(span);
									}
									cidarr[i] = 0;
									//									console.log(cidarr);
								}
							}
							endDate = data.result.data.marketingEndTimeString;
							staDate = data.result.data.marketingStartTimeString;
						} else if(data.result.data.comProductExtVOs) {
							$('.jia').attr('ornum', data.result.data.enableNum);
							sessionStorage.ifzhgoods = 'yes';
							var imgl = data.result.data.imgsrc;
							var imgls = imgl.split(',');
							for(var k = 0; k < imgls.length; k++) {
								var div = ('<div class="swiper-slide"><img src=' + picur + imgls[k] + ' width="100%" height="100%" alt="" /></div>');
								$('.swiper-wrapper').append(div);
							}
							$(function() {
								if(imgls.length == 1) {
									var ifdong = false
								} else if(imgls.length > 1) {
									var ifdong = true
								}
								var mySwiper1 = new Swiper('.banner-swp', {
									autoplay: 3000,
									speed: 300,
									autoplayDisableOnInteraction: false,
									lazyLoading: true, // 图片懒加载
									paginationType: 'bullets',
									pagination: '.swiper-pagination',
									loop: ifdong,
								})
							})
							var pricenew = data.result.data.newPrice;
							$('.zyouprice').text(Math.round(pricenew * 100) / 100);
							$('.name').text(data.result.data.shortName);
							if(data.result.data.newPrice!=data.result.data.price){                      	
//                          	$('.disprice').css('display','block');
                                 
                                
                            	$('.disprice-s').text(Math.round(pricenew * 100) / 100);
                            	
                            	$('.price-s').text(data.result.data.price);
                            	$('.price-d').text(data.result.data.newPrice);
                            	$('.price').css({"text-decoration":"line-through",'color':'#8c9495'});                              	
                            }else if(data.result.data.newPrice==data.result.data.price){
                            	$('.price').css('display','none');
                            	$('.disprice-s').text(data.result.data.price);
                            	$('.price-d').text(data.result.data.price);
                            }
							$('.price-s').text(data.result.data.price);
							$('.pro').text(data.result.data.longName);
							$('#xiang').append(data.result.data.detail);
							$('.descri').text(data.result.data.description);
							localStorage.addcarId = data.result.data.skuid;
							var imgs = $('#xiang img');
							//							console.log(imgs.attr('src'));
							console.log(imgs);
							for(var n = 0; n < imgs.length; n++) {
								//                  	var dimg = imgs[n];
								//                  	dimg.attr('src');
								//								console.log(imgs[n]);
								var dimg = $(imgs[n]).attr('src');
								//								console.log($(imgs[n]).attr('src'));
								if(dimg.indexOf('http')<0){
                                  	$(imgs[n]).attr('src', picur + dimg);
                                  }
							}
							$('#xiang img').css({'width':'100%','display':'block'});
							var zdgoods = data.result.data.comProductExtVOs.length;
							var zhgoodsypri = 0;
							for(var z = 0; z < zdgoods; z++) {

								var zdgoodsd = $('<div class="zcontent" id="' + z + '" wid="' + data.result.data.comProductExtVOs[z].id + '">' +
									'<p>' + data.result.data.comProductExtVOs[z].shortName + '</p>' +
									'<div>' +
									'<div class="zdpic">' +
									'<span style="background-image: url(' + picur + data.result.data.comProductExtVOs[z].imgsrc + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>' +
									'</div>' +
									'<div class="zdtype zdtype' + z + '">' +

									'</div>' +
									'</div>' +
									'<p>¥<span class="pricezd">' + data.result.data.comProductExtVOs[z].price + '</span></p>' +
									'</div>');
								$('.all-zcontent').append(zdgoodsd);
								zhgoodsypri += data.result.data.comProductExtVOs[z].price;
								zhd[z] = 0;
								cidarr[z] = {};
								//							if(data.result.data.comProductExtVOs[z].proMap.length==[]){
								//								
								//							}
								//							alert(data.result.data.comProductExtVOs[z].proMap.length);
								if(data.result.data.comProductExtVOs[z].proMap.length > 0) {
									for(var x = 0; x < data.result.data.comProductExtVOs[z].proMap.length; x++) {
										var div = $('<div class="howsize zhowsize"><p>' + data.result.data.comProductExtVOs[z].proMap[x].arrit + '</p><div class="howd z' + z + 'x' + x + '" id="' + x + '"></div></div>');
										//	                    	console.log(data.result.data.proMap[0].value[0].value);
										//	                    	console.log(data.result.data.proMap[0].value.length);
										$('.zdtype' + z + '').append(div);
										for(var c = 0; c < data.result.data.comProductExtVOs[z].proMap[x].value.length; c++) {
											//                  		console.log(data.result.data.proMap[i].value[y].value);
											var span = $('<span class="' + data.result.data.comProductExtVOs[z].proMap[x].value[c].id + '">' + data.result.data.comProductExtVOs[z].proMap[x].value[c].value + '</span>');
											$('.z' + z + 'x' + x + '').append(span);
										}
										cidarr[z][x] = 0;
										//										console.log(cidarr[z][x]);
									}
								} else if(data.result.data.comProductExtVOs[z].proMap.length == 0) {
									zhd[z] = data.result.data.comProductExtVOs[z].skuid;
								}
							}
							$('.zallprice').text(zhgoodsypri);

						}

					}
				},
				error: function(data) {
					mui.toast('系统错误');
				}
			})
		}

		/*组合商品点击更新价格*/
		//          var cidarr = {"0":0,"1":0};          
		$('.all-zcontent').on('tap', '.howd>span', function() {
			$('.all-zcontent').find('.howd>span');
			$(this).css('background-color', '#e3b436');
			$(this).siblings().css('background-color', '#eeeeee');
			//         	alert($('.howsize').length);
			//         	alert($('.d_how').find('.howd>span').length);
			var spanl = $('.all-zcontent').find('.howd>span').length;
			var seltimes = 0;

			$(this).parents('.zcontent').attr('id')
			for(var o = 0; o < spanl; o++) {
				var cold = $(this).parents('.zcontent').find('.howd>span')[o];
				//         		var cold = $('.all-zcontent').find('.howd>span')[o];
				//				console.log($(cold).css('background-color'));
				if($(cold).css('background-color') == 'rgb(227, 180, 54)') {
					seltimes = seltimes + 1;
					//         			alert(seltimes);
				}
				//				console.log(seltimes);
			}
			//         	sessionStorage.seltimes=seltimes;
			//         	    alert(seltimes);
			//         	    alert($('.howsize').length);
			var cid = $(this).attr('class');
			var cidp = $(this).parents('.howd').attr('id');
			var zcidp = $(this).parents('.zcontent').attr('id');
			//			console.log(cid);
			//			console.log(cidp);
			cidarr[zcidp][cidp] = cid;
			var attribute = [];
			for(var key in cidarr[zcidp]) {
				attribute.push(cidarr[zcidp][key]);
			}
			//			console.log(attribute);
			var zdthis = $(this);
			localStorage.zwhereId = $(this).parents('.zcontent').attr('wid');
			var zdgs = $(this).parents('.zcontent').find('.howsize').length;
			if(zdgs == seltimes) {
				$.ajax({
					url: ur + '/mobile/product/getPrice',
					type: 'post',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.token
					},
					data: {
						"attribute": attribute.sort(function(a, b) {
							return a - b
						}).join(),
						"proudutid": localStorage.zwhereId,
					},
					success: function(data) {
						if(data.result.meta.code == 200) {
							$('.price-s').text(data.result.data.skuArrir.newPrice);
							$('.price-d').text(data.result.data.skuArrir.newPrice);
							$('.sy-jian').text(data.result.data.skuArrir.enableNum);
							$(zdthis.parents('.zcontent').find('.pricezd')).text(data.result.data.skuArrir.newPrice);
							var zdsib = $(zdthis.parents('.zcontent').siblings());
							//							console.log(zdsib);
							var zdpricesib = 0;
							for(var v = 0; v < zdsib.length; v++) {
								$(zdsib[v]).find('.pricezd').text();
								zdpricesib += Number($(zdsib[v]).find('.pricezd').text());
								//								console.log(zdpricesib);
							}
							//	                	alert(zdthis.parents('.zcontent').attr('id')) ;
							$('.zallprice').text(zdpricesib + data.result.data.skuArrir.newPrice);

							zhd[zdthis.parents('.zcontent').attr('id')] = data.result.data.skuArrir.skuId;
							//							console.log(zhd);
						}
						//						
						//						if(data.result.meta.code == 200) {
						//							$('.price-s').text(data.result.data.skuArrir.newPrice);
						//							$('.price-d').text(data.result.data.skuArrir.newPrice);
						//							$('.sy-jian').text(data.result.data.skuArrir.enableNum);
						//							$(zdthis.parents('.zcontent').find('.pricezd')).text(data.result.data.skuArrir.newPrice);
						//							var zdsib = $(zdthis.parents('.zcontent').siblings());
						//							console.log(zdsib);
						//							var zdpricesib = 0;
						//							for(var v = 0; v < zdsib.length; v++) {
						//								$(zdsib[v]).find('.pricezd').text();
						//								zdpricesib += Number($(zdsib[v]).find('.pricezd').text());
						//								console.log(zdpricesib);
						//							}
						//							//	                	alert(zdthis.parents('.zcontent').attr('id')) ;
						//							$('.zallprice').text(zdpricesib + data.result.data.skuArrir.newPrice);
						//
						//							zhd[zdthis.parents('.zcontent').attr('id')] = data.result.data.skuArrir.skuId;
						//							console.log(zhd);
						//						}
					}
				})
			}
		})

		/*组合商品确定加入购物车*/
		$('.zsure-go').on('tap', function() {
			//			   alert(ifcanbug);
			var ifzs = true;
			var skuArrs = "";

			//检查数据====start
			for(var key in zhd) {
				if(zhd[key] == 0) {
					ifzs = false;
					skuArrs = "";
					break;
				}
				skuArrs += zhd[key] + ":";
			}
			//      	console.log(skuArrs);
			if(ifzs == false) {
				mui.toast('请选择商品属性');
			} else if(ifzs == true) {
				zaddcar(skuArrs.substring(0, skuArrs.lastIndexOf(":")));
			}

		})
		//检查数据====end

		/*组合商品加入购物车*/
		function zaddcar(skuArrs) {
			$.ajax({
				url: ur + '/mobilemember/shoppingcart/addcart',
				type: 'post',
				dataType: 'json',
				headers: {
					"X-Token": localStorage.token
				},
				data: {
					"shoppingcartVO.number": $('.zhowjiad').text(),
					"shoppingcartVO.productSkuId": localStorage.addcarId,
					"shoppingcartVO.comSkuIds": skuArrs
				},
				success: function(data) {
					getinfor();
					//					console.log(data);
					if(data.result.meta.code == 200) {
						$('.zblack-men').css('display', 'none');
						mui.toast('加入购物车成功');
						getinfor();
					} else if(data.result.meta.code == 201) {
						mui.toast('请先登录');
					} else if(data.result.meta.code == 303) {
						mui.toast('登录过期，请重新登录');
					}
				}
			})
		}

		/*点击更新价格*/
		//          var cidarr = {"0":0,"1":0};          
		$('.d_how').on('tap', '.howd>span', function() {
			$('.d_how').find('.howd>span');
			$(this).css('background-color', '#e3b436');
			$(this).siblings().css('background-color', '#eeeeee');
			//         	alert($('.howsize').length);
			//         	alert($('.d_how').find('.howd>span').length);
			var spanl = $('.d_how').find('.howd>span').length;
			var seltimes = 0;
			for(var o = 0; o < spanl; o++) {

				var cold = $('.d_how').find('.howd>span')[o];
				//				console.log($(cold).css('background-color'));
				if($(cold).css('background-color') == 'rgb(227, 180, 54)') {
					seltimes = seltimes + 1;
					//         			alert(seltimes);
				}
				//				console.log(seltimes);
			}
			sessionStorage.seltimes = seltimes;
			//         	    alert(seltimes);
			//         	    alert($('.howsize').length);
			var cid = $(this).attr('class');
			var cidp = $(this).parents('.howd').attr('id');
			//			console.log(cid);
			//			console.log(cidp);
			cidarr[cidp] = cid;
			var attribute = [];
			for(var key in cidarr) {
				attribute.push(cidarr[key]);
			}
			//				console.log(attribute);
			if($('.howsize').length == seltimes) {
				$.ajax({
					url: ur + '/mobile/product/getPrice',
					type: 'post',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.token
					},
					data: {
						"attribute": attribute.sort(function(a, b) {
							return a - b
						}).join(),
						"proudutid": localStorage.whereId,
					},
					success: function(data) {
						if(data.result.meta.code == 200) {
							$('.disprice-s').text(data.result.data.skuArrir.newPrice);
							$('.price-s').text(data.result.data.skuArrir.price);
							$('.price-d').text(data.result.data.skuArrir.newPrice);
							$('.sy-jian').text(data.result.data.skuArrir.enableNum);
							localStorage.addcarId = data.result.data.skuArrir.skuId;
							//							console.log(data);

						}
						//						if(data.result.meta.code == 200) {
						//							$('.price-s').text(data.result.data.skuArrir.newPrice);
						//							$('.price-d').text(data.result.data.skuArrir.newPrice);
						//							$('.sy-jian').text(data.result.data.skuArrir.enableNum);
						//							localStorage.addcarId = data.result.data.skuArrir.skuId;
						//							console.log(data);
						//
						//						}
					}
				})
			}
		})

		var pagenow = 1;
		/*点击查看更多*/
		$('.morelcom').on('tap', function() {
			discuss();
		});
//		小离
var numPhoto = '';
		discuss1();
		function discuss1() {
			$.ajax({
				url: ur + '/mobilemember/comment/productcommentlist',
				type: 'post',
				dataType: 'json',
				data: {
					"id": localStorage.whereId,
					"numPerPage": '',//分页中每页显示多少条
					"pageNum": '',//是分页中的第几页
					"pageRequest": '1'
				},
				success: function(data) {
					if(data.status == 200) {
						sessionStorage.wyShopPase = data.content.length;
						$('#mainNum').text(sessionStorage.wyShopPase);
						var num = data.content.length;
						for(var i = 0;i<num;i++){
							if(data.content[i].photo) {
								console.log(i+'全部个数')
								numPhoto++;
							}else{
								for(var zj1 = 0;zj1 <data.content[i].appendCmt.length;zj1++){
									if(data.content[i].appendCmt[zj1].photo){
										console.log(i+'全部个数')
										numPhoto++;
										break;
									}
								}
							}
						}
//						alert(numPhoto+'全部个数')
						$('.all-comm-pic').text(numPhoto);//晒图数量
						if(numPhoto==0){
							$('.all-comm-pic').text('0');
						}else{
							$('.all-comm-pic').text(numPhoto);
						}
					}
				},
			})
		}
//小离结束
		/*展示商品评论*/
		//		discuss();
		function discuss() {
			$.ajax({
				url: ur + '/mobilemember/comment/productcommentlist',
				type: 'post',
				dataType: 'json',

				data: {
					"id": localStorage.whereId,
					"numPerPage": '5',
					"pageNum": pagenow,
					"pageRequest": '1'
				},
				success: function(data) {
					//					console.log(data);

					//                    $('.all-comm-pic').text(data.content.length);
					if(data.status == 200) {
						pagenow++

						$('.all-comm').text(data.paginator.totalCount);
						$('.per').text(data.content.length);
						var cmtTime = data.content[0].cmtTime.substring(0, 10);
						$('.per').text(data.content.length);
						$('.fevaname').text(data.content[0].nickName.substr(0, 6));
						$('.fevatime').text(cmtTime);
						$('.fc-content').text(data.content[0].content);
						$('.headpicd').css('background-image', 'url(' + picur + data.content[0].ufHeadPhoto + ')')
						for(var i = 0; i < data.content.length; i++) {
							var div = $('<div class="comment"> ' +
								'<div class="fircom">' +
								'<div class="comm-c"> ' +
								'<p><span class="headpic" style="background-image: url(' + picur + data.content[i].ufHeadPhoto + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span><span class="name11">' + data.content[i].nickName.substr(0, 6) + '</span>' +
								//                                   '<img class="grade" src="img/turn-right.png"></p> ' +
								'<p>' + data.content[i].cmtTime.substr(0, 10) + '</p> </div> ' +
								//                                   '<p class="taste">口感<span>5</span></p> ' +
								//                                   '<p class="level">颜值<span>5</span></p> ' +
								'<p class="c-content">' + data.content[i].content + '</p> ' +
								'<div class="imgs img' + i + '">' +
								//                                   '<span></span>'+
								'</div>' +
								'<div style="text-align: right;">' + data.content[i].size + '</div>' +
								'<div class="sreply' + i + '"><p></p><p><span>客服回复：</span><span>' + data.content[i].replyContent + '</span></p></div>' +
								'</div>' +
								'<div class="morecom' + i + ' morecom"></div>' +
								'</div>')

							$('.comm').append(div.clone());
							if(data.content[i].photo != '') {
								$('.comm-pic').append(div);
								//								$('.comm').append(div);
								var imgd = data.content[i].photo.split(',');
								console.log(imgd);
								console.log(imgd[0]);
								var imgspan = $('<span style="background-image: url(' + comcur + imgd[0] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>' +
									'<span style="background-image: url(' + comcur + imgd[1] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>' +
									'<span style="background-image: url(' + comcur + imgd[2] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>');
								$('.img' + i + '').append(imgspan);
							}

							if(data.content[i].replyContent == '' || data.content[i].replyContent == null) {
								$('.sreply' + i + '').css('display', 'none');
							}
							if(data.content[i].appendCmt.length > 0) {
								for(var k = 0; k < data.content[i].appendCmt.length; k++) {
									var modiv = $('<div class="addcomd">' +
										'<p class="c-content">' + data.content[i].appendCmt[k].content + '</p> ' +
										'<div class="imgs aimg' + i + '' + k + '">' +
										//                                   '<span></span>'+
										'</div>' +
										'<p class="addcomt"><span>追加评论</span><span>' + data.content[i].appendCmt[k].cmtTime.substring(0, 10) + '</span></p>' +
										'<div class="asreply' + i + '' + k + '"><p></p><p><span>客服回复：</span><span>' + data.content[i].appendCmt[k].replyContent + '</span></p></div>' +
										'</div>');
									$('.morecom' + i + '').append(modiv);
									var aimgd = data.content[i].appendCmt[k].photo.split(',');
									console.log(aimgd);
									console.log(aimgd[0]);
									var aimgspan = $('<span style="background-image: url(' + comcur + aimgd[0] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>' +
										'<span style="background-image: url(' + comcur + aimgd[1] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>' +
										'<span style="background-image: url(' + comcur + aimgd[2] + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></span>');
									$('.aimg' + i + '' + k + '').append(aimgspan);

									if(data.content[i].appendCmt[k].replyContent == '' || data.content[i].appendCmt[k].replyContent == null) {
										$('.asreply' + i + '' + k + '').css('display', 'none');
									}
								}
							} else if(data.content[i].appendCmt.length == '') {
								$('.morecom' + i + '').css('display', 'none');
							}
						}
						//                       alert($('.comm>div').length);
						if(data.paginator.totalCount == $('.comm>div').length) {
							$('.morelcom').text('已无更多');
						}
						$('.morelcom').off('tap');
//						$('.all-comm-pic').text($('.comm-pic>div').length);
					} else if(data.status == 201) {
						$('.look-all-comm').text('暂时没有评论');
						$('.comment-mei').css('display', 'none');
						$('.all-comm').text(0);
						$('.morelcom').text('此商品暂无评论');
						$('.morelcom').off('tap');
//						$('.all-comm-pic').text(0);
					}
				},
				error: function(data) {
					//                	mui.toast('系统错误获取评论失败');
				}
			})

		}

		/*获取默认收货地址*/
		showaddress();

		function showaddress() {
			$.ajax({
				url: ur + '/mobilemember/frontmember/getDefauReceiAddr',
				type: 'post',
				dataType: 'json',
				headers: {
					"X-Token": localStorage.token
				},
				data: '',
				success: function(data) {
					//					console.log(data);
					$('.address-d').text(data.result.data.area);
				}
			})
		}

		/*加入购物车*/
		$('.addcarc').on('tap', function() {
			//			alert(111);
			//			alert(sessionStorage.ifcanbug);

			if(sessionStorage.ifcanbug&&sessionStorage.ifcanbug == 0) {
					mui.toast('活动已结束，不能加入购物车');
				} else if(sessionStorage.ifcanbug&&sessionStorage.ifcanbug == 2) {
					mui.toast('活动未开始，不能加入购物车');
				} else if(sessionStorage.ifcanbug&&sessionStorage.ifcanbug == 1) {
					if(sessionStorage.ifzhgoods == 'noo') {
						$('.black-men').css('display', 'block');
					} else if(sessionStorage.ifcanbug&&sessionStorage.ifzhgoods == 'yes') {
						$('.zblack-men').css('display', 'block');
					}
				}
		});

		/*取消弹框*/
		$('.cancel').on('tap', function() {
			$('.black-men').css('display', 'none');
		});

		$('.cancel').on('tap', function() {
			$('.zblack-men').css('display', 'none');
		});

		/*获取购物车商品信息*/
		getinfor();

		function getinfor() {
			//			console.log('运行');
			var allcart = 0;
			$.ajax({
				url: ur + '/mobilemember/shoppingcart/listshoppingcart',
				type: 'post',
				dataType: 'json',
				headers: {
					"X-Token": localStorage.token
				},
				data: '',
				success: function(data) {
					if(data.result.meta.code == 200) {
						//						console.log(data);
						var times = data.result.data.length;
						//						console.log(data.result.data.length);
						for(var y = 0; y < data.result.data.length; y++) {
							allcart += data.result.data[y].number;
						}
						$('.how-all').text(allcart);
					}
				},
				error: function(data) {}
			})
		}

		/*确定加入购物车*/
		$('.sure-go').on('tap', function() {

			if(Number(sessionStorage.seltimes) !== $('.howsize').length) {
				mui.toast('请选择商品属性');
			} else if(Number(sessionStorage.seltimes) == $('.howsize').length) {
				addcar();
				//                alert('加入');
			}
			var howjiand = $('.howjiad').text();
		})

		/*加入购物车接口*/
		function addcar() {
			//			          alert($('.howjiad').text());

			if(enterp == '') {
				var data = {
					"shoppingcartVO.number": $('.howjiad').text(),
					"shoppingcartVO.productSkuId": localStorage.addcarId
				}
			} else if(enterp != '') {
				var data = {
					"shoppingcartVO.number": $('.howjiad').text(),
					"shoppingcartVO.productSkuId": localStorage.addcarId,
					"shoppingcartVO.enterProductId": enterp
				}
			}

			$.ajax({
				url: ur + '/mobilemember/shoppingcart/addcart',
				type: 'post',
				dataType: 'json',
				headers: {
					"X-Token": localStorage.token
				},
				data: data,
				success: function(data) {

					getinfor();
					//					console.log(data);
					if(data.result.meta.code == 200) {
						$('.black-men').css('display', 'none');
						mui.toast('加入购物车成功');
						getinfor();
					} else if(data.result.meta.code == 201) {
						mui.toast('请先登录');
					} else if(data.result.meta.code == 303) {
						mui.toast('登录过期，请重新登录');
					}
				}
			})
		}

		/*点击跳转购物车*/
		function hrefgo(a, b) {
			mui.openWindow({
				url: a,
				id: b,
				show: 'pop-in',

			})
		}

		/*营销活动倒计时*/
		var endDate = "";
		var staDate = "";
		sessionStorage.ifcanbug = "";

		function tab() {
			//									alert(endDate);
			//			console.log(staDate);
			//									console.log(endDate);
			//			console.log(endDate);
			//console.log($(endDate).replaceAll(":",","));
			var nowDate = new Date();
			if(endDate == '' || staDate == '' || staDate == null || endDate == null) {
				//										alert(endDate);
				//										alert(staDate);
				sessionStorage.ifcanbug = 1;
				$('.alltye').css('display', 'none');
				return;
			} else if(endDate != '' && staDate != '' && staDate != null || endDate != null) {
				var oDate2 = new Date(endDate);
				var oDate1 = new Date(staDate);
				//				console.log(oDate1.getTime());
				//				console.log(oDate2.getTime());
				//				console.log(oDate2);
				//				console.log(nowDate.getTime());

				//							 console.log(date);
				if(nowDate.getTime() > oDate2.getTime()) {
					//	活动已经结束				        
					var chahm = nowDate.getTime() - oDate2.getTime();
					sessionStorage.ifcanbug = 0;

					$('.alltye').text('活动已结束')
				} else if(nowDate.getTime() < oDate2.getTime() && nowDate.getTime() > oDate1.getTime()) {
					//  活动进行中
					//					        console.log('第二个大');
					//							console.log(typeof(date1.getTime()));
					//							console.log(typeof(oDate2.getTime()));
					//					        console.log(  oDate2.getTime()-date1.getTime());
					//									var chadata = new Date(oDate2.getTime() - nowDate.getTime());
					//					        console.log(chadata);
					var chahm = oDate2.getTime() - nowDate.getTime();
					$('.actity').text('距结束');
					sessionStorage.ifcanbug = 1;
				} else if(nowDate.getTime() < oDate1.getTime()) {
					//活动未开始
					var chahm = oDate1.getTime() - nowDate.getTime()
					$('.actity').text('距开始');
					sessionStorage.ifcanbug = 2;
				}
				console.log(chahm);
				var chaDate = new Date(chahm);
				console.log(chaDate);
				//								var nD = Math.floor(chahm / (1000 * 60 * 60 * 24));
				//								var nH = Math.floor(chahm / (1000 * 60 * 60)) % 24;
				var nH = Math.floor(chahm / (1000 * 60 * 60));
				var nM = Math.floor(chahm / (1000 * 60)) % 60;
				var nS = Math.floor(chahm / 1000) % 60;
				//						    console.log(nD);
				//						    console.log(nH);
				//						    console.log(nM);
				//						    console.log(nS);
				//								$('.hmd').text(nD);
				//                              if(){
				//                              	
				//                              }
				$('.hms').text(nH);
				$('.hmf').text(nM);
				$('.hmm').text(nS);
			}
		}

		setInterval('tab()', 1000);
	</script>

</html>